﻿using BackupContracts.Sql;
using BackupContracts.Tasks;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WebRole.Test.BackupServiceReference;

namespace WebRole.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, errors) => 
            {
                return true;
            };

            Console.ReadLine();

            var backupServiceClient = new BackupServiceClient();
            backupServiceClient.ClientCredentials.UserName.UserName = "admin";
            backupServiceClient.ClientCredentials.UserName.Password = "Pa$$w0rd";
            var backupService = (IBackupService)backupServiceClient;

            //backupService.UpsertSqlServer(new SqlServer()
            //{
            //    Id = "1CC63232-94DB-46FA-BE9A-CB2D81D54DE0",
            //    Name = "yu5x7ybuwn",
            //    User = "vitor",
            //    Password = "Pa$$w0rd",
            //});

            //var task = new Task()
            //{
            //    Id = "2CC63232-94DB-46FA-BE9A-CB2D81D54DE0",
            //    Name = "Task 1",
            //    Enabled = true,
            //};
            //task.Schedules = new System.Collections.ObjectModel.ObservableCollection<Schedule>();
            //task.Schedules.Add(new Schedule() { 
            //    ScheduleType = ScheduleType.Daily,
            //    Start = new DateTimeOffset(new DateTime(2013,01,01, 0, 0, 0)),
            //    RecurEveryX = 1,
            //    LastExecution = null,
            //});
            //task.Actions = new System.Collections.ObjectModel.ObservableCollection<TaskAction>();
            //task.Actions.Add(new SqlBackupTaskAction()
            //{
            //    Database = new SqlDatabase() 
            //    {
            //        Name = "testemobileservices_db",
            //        ServerId = "1CC63232-94DB-46FA-BE9A-CB2D81D54DE0",
            //    }
            //});
            //backupService.UpsertTask(task);

            backupService.CopyAndBackupToBlob("yu5x7ybuwn", "testemobileservices_db", "vitor", "Pa$$w0rd", "azuresqlbackup1", "9tUZB2qcKM/WUewUZ8uaHiAEeO/ymtJQ84xWJR7/tRiAFPhPRSWZCnTwlzfu2eS75L6xH2obz3TU5EtuopNWgA==", "backups", 10);

            Console.ReadLine();
        }
    }
}
